<template>
	<u-scroll-list :indicator="indexGrid.length > 4" indicatorColor="#ccc" indicatorActiveColor="#00FFAA" :indicatorWidth="24" :indicatorBarWidth="12">
		<view v-for="(item,idx) in indexGrid" :key="idx" @click="change(item)">
			<view class="flex flex-dir-col flex-js-center flex-ai-center" style="width: 141rpx">
				<w-image :src="item.image" width="37" height="37" mode="aspectFit"></w-image>
				<text class="font-size-12 font-color-textPrimary mt-8">{{ item.name }}</text>
			</view>
		</view>
	</u-scroll-list>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		name: "w-grid",
		computed: {
			...mapState('config', {
				indexGrid(state) {

					let data = state.pageConfig.find(v => v.type == 'menu' && v.category == 'home')
					if (data) {
						return data.content.list
					}
					return []
				}
			})
		},
		data() {
			return {

			};
		},
		methods: {
			change({
				path
			}) {
				if (!path) {
					return uni.showToast({
						icon: 'none',
						title: "敬请期待!"
					})
				}
				if (!this.isLogin) {
					return uni.$emit('showLogin')
				}

				if (path.startsWith('/')) {
					// if(path=='/pages/invitation/invitation' && this.userInfo.get_yaoqing!=1){
					// 	uni.showToast({ title: '暂无分享权限',icon: 'none' })
					// 	return
					// }
					return this.$u.route(path)
				}
				if (path.includes('mayi.art/#/pages')) {
					let url = path.split('mayi.art/#')[1]
					return this.$u.route(url)
				} else if (path.startsWith('https://mp.weixin.qq.com/')) {
					// #ifdef H5
					window.location.href = path
					// #endif
					// #ifdef APP-PLUS
					this.toLocalWebview(path)
					// #endif
				} else {
					this.toLocalWebview(path)
				}

			}
		}
	}
</script>

<style lang="scss" scoped>
	/deep/ .u-scroll-list__indicator {
		margin-top: 14rpx !important;
	}
</style>